package cn.powertime.evaluation.shiro;

import cn.powertime.evaluation.vo.ShiroUserInfo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;

/**
 * <p>
 *
 * </p>
 *
 * @author ZYW
 * @version v1.0.0
 * @date 2019-09-02 15:51
 */
public class ShiroUtils {
    /** 私有构造器 **/
    private ShiroUtils(){ }

    /**
     * 获取当前用户Session
     * @Author Sans
     * @CreateTime 2019/6/17 17:03
     * @Return SysUserEntity 用户信息
     */
    public static Session getSession() {
        return SecurityUtils.getSubject().getSession();
    }

    /**
     * 用户登出
     * @Author Sans
     * @CreateTime 2019/6/17 17:23
     */
    public static void logout() {
        SecurityUtils.getSubject().logout();
    }

    /**
     * 获取当前用户信息
     * @Author Sans
     * @CreateTime 2019/6/17 17:03
     * @Return SysUserEntity 用户信息
     */
    public static ShiroUserInfo getUserInfo() {
        return (ShiroUserInfo) SecurityUtils.getSubject().getPrincipal();
    }
}
